<?php
namespace app\front\logic;
use think\facade\Db;

class ActivityLogic{
	public static $init;
	static function init(){
		if (!isset(self::$init)) {//判断是否以前创建了当前类的实例
            $c = __CLASS__;//获取类名
            self::$init = new static;//如果没有创建，实例化当前类，这里实现类只实例化一次
        }
        return self::$init;//返回类的实例
	}

	function getActivityDistinct($lang='zh', $level=1){
		$fields = "";
		if($lang=='zh'){
			$fields .= 'r.item_name as name, r.extension, rl.item_name, rl.amount, rl.gift_rate';
		}else{
			$fields .= 'r.item_name_en as name, r.extension_en as extension
						, rl.item_name_en as item_name, rl.amount, rl.gift_rate';
		}
		// echo $fields;
		$list = Db::name('recharge')
				->alias('r')
				->field($fields)
				->join('recharge_level rl','rl.recharge_id=r.id')
				->where('r.status', 1)
				->where('rl.grade_level', $level)
				->order('r.id desc, rl.amount desc')
				->select()
				->toArray();
		return $list;
	}
	
}